import 'package:elephant_fish/model/anchor_entity.dart';
import 'package:elephant_fish/model/contribute_rank_entity.dart';
import 'package:elephant_fish/model/family_entity.dart';
import 'package:elephant_fish/util/size_util.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class NewRankList extends StatefulWidget {
  final AnchorEntity anchorEntity;
  final FamilyEntity familyEntity;
  final ContributeRankEntity contributeRankEntity;
  final int index;
  final int rankNum;
  const NewRankList({Key key, this.anchorEntity, this.familyEntity, this.contributeRankEntity, this.index, this.rankNum}) : super(key: key);

  @override
  _NewRankListState createState() => _NewRankListState();
}

class _NewRankListState extends State<NewRankList> {
  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    return
      widget.rankNum == 0 ?
      Container(
      height: 60,
      child:  Row(
        children: [
          SizedBox(width: 17,),
          Container(
            width: 22,
            height: 19,
            decoration: BoxDecoration(
              image: DecorationImage(
                  image: AssetImage('assets/images/rankheart.png')),
            ),
            child: Center(
              child: Text(widget.index.toString(),style: TextStyle(color: Color(0xffffffff),fontSize: 12),),
            ),
          ),
          SizedBox(width: 14,),
          Stack(
            children: [
              Container(
                width: 34,
                height: 34,
                child:   CircleAvatar(
                  backgroundImage: NetworkImage(
                    'http://119.28.131.94:82' +widget.anchorEntity.avatar),
                  radius: 34,
                ),
              )

            ],
          ),
          SizedBox(width: 17.5,),
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Row(children: [
                Text(widget.anchorEntity.nickname,style: TextStyle(color: Color(0xfff3f3f3),fontSize: 15),),
                SizedBox(width: 3,),
                widget.anchorEntity.sex == '男' ? 
                Image.asset('assets/images/personal_boy.png',width: 13,height: 13,):
                Image.asset('assets/images/personal_girl.png',width: 13,height: 13,),
              ],),
              SizedBox(width: 3.5,),
              widget.anchorEntity.anchorTitle == '常在'
                  ? Image.asset(
                'assets/images/changzaiicon.png',
                height: 12,
              )
                  : widget.anchorEntity.anchorTitle == '良人'
                  ? Image.asset(
                'assets/images/liangrenicon.png',
                height: 12,
              )
                  : widget.anchorEntity.anchorTitle == '贵嫔'
                  ? Image.asset(
                'assets/images/guipinicon.png',
                height: 12,
              )
                  : widget.anchorEntity.anchorTitle ==
                  '贵妃'
                  ? Image.asset(
                'assets/images/guifeiicon.png',
                height: 12,
              )
                  : widget.anchorEntity.anchorTitle ==
                  '皇后'
                  ? Image.asset(
                'assets/images/huanghouicon.png',
                height: 12,
              )
                  : widget.anchorEntity.anchorTitle ==
                  '神女'
                  ? Image.asset(
                'assets/images/shennvicon.png',
                height: 12,
              )
                  : widget.anchorEntity.anchorTitle ==
                  '帝后'
                  ? Image.asset(
                'assets/images/dihouicon.png',
                height: 12,
              )
                  : widget.anchorEntity.anchorTitle ==
                  '天君夫人'
                  ? Image.asset(
                'assets/images/tianjunfurenicon.png',
                height:
                12,
              )
                  : Image.asset(
                'assets/images/nvwaicon.png',
                height:
                12,
              )
            ],
          ),
          SizedBox(width: SizeUtil.px(size.width - 120),),
          Text(widget.anchorEntity.number,style: TextStyle(color: Color(0xfffe4853),fontSize: 15),),
        ],
      ),
    ) :
      widget.rankNum == 1 ?
      Container(
        height: 60,
        child:  Row(
          children: [
            SizedBox(width: 17,),
            Container(
              width: 22,
              height: 19,
              decoration: BoxDecoration(
                image: DecorationImage(
                    image: AssetImage('assets/images/rankheart.png')),
              ),
              child: Center(
                child: Text(widget.index.toString(),style: TextStyle(color: Color(0xffffffff),fontSize: 12),),
              ),
            ),
            SizedBox(width: 14,),
            Stack(
              children: [
                Container(
                  width: 34,
                  height: 34,
                  child:   CircleAvatar(
                    backgroundImage: NetworkImage(
                      'http://119.28.131.94:82' +widget.contributeRankEntity.avatar,),
                    radius: 34,
                  ),
                )

              ],
            ),
            SizedBox(width: 17.5,),
            Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Row(children: [
                  Text(widget.contributeRankEntity.nickname,style: TextStyle(color: Color(0xfff3f3f3),fontSize: 15),),
                  SizedBox(width: 3,),
                  widget.contributeRankEntity.sex == '男' ?
                  Image.asset('assets/images/personal_boy.png',width: 13,height: 13,):
                  Image.asset('assets/images/personal_girl.png',width: 13,height: 13,),
                ],),
                SizedBox(width: 3.5,),
                widget.contributeRankEntity.title == '平民'
                    ? Image.asset(
                  'assets/images/pinmingicon.png',
                  height: 12,
                )
                    : widget.contributeRankEntity
                    .title ==
                    '子爵'
                    ? Image.asset(
                  'assets/images/zijueicon.png',
                  height: 12,
                )
                    : widget.contributeRankEntity
                    .title ==
                    '伯爵'
                    ? Image.asset(
                  'assets/images/bojueicon.png',
                  height: 12,
                )
                    : widget.contributeRankEntity
                    .title ==
                    '亲王'
                    ? Image.asset(
                  'assets/images/qinwangicon.png',
                  height: 12,
                )
                    : widget.contributeRankEntity
                    .title ==
                    '皇帝'
                    ? Image.asset(
                  'assets/images/huangdiicon.png',
                  height: 12,
                )
                    : widget.contributeRankEntity
                    .title ==
                    '神'
                    ? Image.asset(
                  'assets/images/shenicon.png',
                  height: 12,
                )
                    : widget.contributeRankEntity
                    .title ==
                    '大帝'
                    ? Image.asset(
                  'assets/images/dadiicon.png',
                  height:
                  12,
                )
                    : widget.contributeRankEntity
                    .title ==
                    '天君'
                    ? Image
                    .asset(
                  'assets/images/tianjunicon.png',
                  height:
                  12,
                )
                    : Image
                    .asset(
                  'assets/images/zaowuzhuicon.png',
                  height:
                  12,
                )
              ],
            ),
            SizedBox(width: SizeUtil.px(size.width - 120),),
            Text(widget.contributeRankEntity.number,style: TextStyle(color: Color(0xfffe4853),fontSize: 15),),
          ],
        ),
      ) :
      Container(
        height: 60,
        child:  Row(
          children: [
            SizedBox(width: 17,),
            Container(
              width: 22,
              height: 19,
              decoration: BoxDecoration(
                image: DecorationImage(
                    image: AssetImage('assets/images/rankheart.png')),
              ),
              child: Center(
                child: Text(widget.index.toString(),style: TextStyle(color: Color(0xffffffff),fontSize: 12),),
              ),
            ),
            SizedBox(width: 14,),
            Stack(
              children: [
                Container(
                  width: 34,
                  height: 34,
                  child:   CircleAvatar(
                    backgroundImage: NetworkImage(
                      'http://119.28.131.94:82' + widget.familyEntity.icon
                        ),
                    radius: 34,
                  ),
                )

              ],
            ),
            SizedBox(width: 17.5,),
            Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Row(children: [
                  Text(widget.familyEntity.name,style: TextStyle(color: Color(0xfff3f3f3),fontSize: 15),),
                ],),
              ],
            ),
            SizedBox(width: SizeUtil.px(size.width - 120),),
            Text(widget.familyEntity.totalContribution,style: TextStyle(color: Color(0xfffe4853),fontSize: 15),),
          ],
        ),
      ) ;
  }
}
